package com.huawang.mdesign.model.service.controller;

import com.huawang.mdesign.model.service.vo.BaseResponse;
import com.huawang.mdesign.model.service.dto.ConnectionPointReferenceClassificationPointDTO;
import com.huawang.mdesign.model.service.dto.DragBehaviorToStateDTO;
import com.huawang.mdesign.model.service.inter.StateMachinesService;
import com.huawang.business.vo.ModelResultVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@Tag(name = "状态机")
@RestController
@RequestMapping("/stateMachines")
@Validated
public class StateMachinesController {

    private final StateMachinesService stateMachinesService;

    public StateMachinesController(StateMachinesService stateMachinesService) {
        this.stateMachinesService = stateMachinesService;
    }

    @Operation(summary = "判断区域内是否已经存在起始状态")
    @GetMapping("/checkPseudostateInitial")
    public BaseResponse<Boolean> validateRegionExistPseudostateInitial(String projectId, String instanceId) {
        return BaseResponse.success(stateMachinesService.isExistPseudostateInitial(projectId, instanceId));
    }

    @Operation(summary = "拖拽模型到状态上")
    @PostMapping("/dragBehaviorToState")
    public BaseResponse<ModelResultVo> dragBehaviorToState(@RequestBody DragBehaviorToStateDTO dragBehaviorToStateDto) {
        return BaseResponse.success(stateMachinesService.dragBehaviorToState(dragBehaviorToStateDto));
    }

    @Operation(summary = "结合连接器分类设置出入口点")
    @PostMapping("/addPoint")
    public BaseResponse<ModelResultVo> connectionPointReferenceClassificationPoint(
            @RequestBody ConnectionPointReferenceClassificationPointDTO connectionPointReferenceClassificationPointDto) {
        return BaseResponse.success(stateMachinesService.connectionPointReferenceClassificationSetPoint(
                connectionPointReferenceClassificationPointDto));
    }

    @Operation(summary = "判断伪态的传入/传出")
    @GetMapping("/checkPseudoStateIncomingOrOutgoing")
    public BaseResponse<Boolean> validatePseudoStateExistIncomingOrOutgoing(String projectId, String instanceId) {
        return BaseResponse.success(stateMachinesService.isExistIncomingOrOutgoing(projectId, instanceId));
    }

}
